//package _Banque._TUN;

//import _Banque.*;
//import _Tests.*;
//
// IUT de Nice / Departement informatique / Module APO-Java
// Annee 2011_2012 - Package _Banque
//
// Classe CompteCourant V 1.1.0 - Tests unitaires de le methode executer
//
// Auteur : S.Estevane Y.Michel
//

public class T_CompteCourant_N3_1 {

   public static void main (String[] args) throws IPException, BUException {

      Tests.Begin("_Banque.CompteCourant", "1.0.0");

      Banque b = new Banque();

      String adresse_1= "Imm. Les Magnolias Bat. 2, 8 Bd Napoleon III - NICE (06000)";
      String adresse_2= "Villa Beau Sejour, 115 Av. de la Grande Armee - PARIS (75000)";

      Tests.Design("Controle du service executer", 3);

      Tests.Case("Cas d'un seul compte"); {

      CompteCourant c1 = new CompteCourant(b, new Titulaire("DUPUY", "Melanie",
      										  "1978/04/25", adresse_1));

         c1.executer("Guichet 322455", 'V', 200f);

         Tests.Unit(200.0f,  c1.getSoldeCompte());
         Tests.Unit(1,       c1.getNombreOperations());

         c1.executer("Guichet 322455", 'V', 320.5f);

         Tests.Unit(520.5f,  c1.getSoldeCompte());
         Tests.Unit(2,       c1.getNombreOperations());

         c1.executer("Facture 2009-29", 'R', 400f);

         Tests.Unit(120.5f,  c1.getSoldeCompte());
         Tests.Unit(3,       c1.getNombreOperations());

         c1.executer("Guichet 322455", 'V', 100f);

         Tests.Unit(220.5f,  c1.getSoldeCompte());
         Tests.Unit(4,       c1.getNombreOperations());
      }

      Tests.Case("Cas de plusieurs comptes"); {
    	  CompteCourant c1 = new CompteCourant(b, new Titulaire("DUPUY", "Melanie",
    	  										  "1978/04/25", adresse_1));

          CompteCourant c2 = new CompteCourant(b, new Titulaire("DURAND", "Paul",
          										  "1981/01/03", adresse_2));

         c1.executer("Guichet 322455", 'V', 200f);
         c1.executer("Guichet 322455", 'V', 320.5f);
         c1.executer("Facture 2009-29", 'R', 400f);
         c1.executer("Guichet 322455", 'V', 100f);

         Tests.Unit(220.5f,  c1.getSoldeCompte());
         Tests.Unit(4,       c1.getNombreOperations());

         c2.executer("Guichet 322455", 'V', 350f);

         Tests.Unit(350.f,  c2.getSoldeCompte());
         Tests.Unit(1,      c2.getNombreOperations());

         c2.executer("Facture 2009-29", 'R', 300f);

         Tests.Unit(50.f,  c2.getSoldeCompte());
         Tests.Unit(2,     c2.getNombreOperations());
      }

      Tests.Case("Cas de l'augmentation de la taille de l'historique"); {
    	  CompteCourant c1 = new CompteCourant(b, new Titulaire("DUPUY", "Melanie",
    	  										  "1978/04/25", adresse_1));

         // Premiere serie de 10 operations
         //
         c1.executer("Guichet 322455", 'V', 200f);
         c1.executer("Guichet 322455", 'V', 320.5f);
         c1.executer("Facture 2009-29", 'R', 400f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Facture 2009-29", 'R', 20.5f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Facture 2009-29", 'R', 100f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Facture 2009-29", 'R', 100f);
         c1.executer("Guichet 322455", 'V', 100f);

         Tests.Unit(300.f,  c1.getSoldeCompte());
         Tests.Unit(10,     c1.getNombreOperations());

         // Deuxi�me serie d'operations
         //
         c1.executer("Facture 2009-29", 'R', 100f);

         Tests.Unit(200.f,  c1.getSoldeCompte());
         Tests.Unit(11,     c1.getNombreOperations());

         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Guichet 322455", 'V', 100f);
         c1.executer("Guichet 322455", 'V', 100f);

         Tests.Unit(1200.f,  c1.getSoldeCompte());
         Tests.Unit(21,      c1.getNombreOperations());
      }

Tests.End();

   }
   }

